package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlPayouts;
import com.ruoyi.hotel.service.IHlPayoutsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物品赔付Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hlpayouts")
public class HlPayoutsController extends BaseController
{
    @Autowired
    private IHlPayoutsService hlPayoutsService;

    /**
     * 查询物品赔付列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlPayouts hlPayouts)
    {
        startPage();
        List<HlPayouts> list = hlPayoutsService.selectHlPayoutsList(hlPayouts);
        return getDataTable(list);
    }

    /**
     * 导出物品赔付列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:export')")
    @Log(title = "物品赔付", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlPayouts hlPayouts)
    {
        List<HlPayouts> list = hlPayoutsService.selectHlPayoutsList(hlPayouts);
        ExcelUtil<HlPayouts> util = new ExcelUtil<HlPayouts>(HlPayouts.class);
        util.exportExcel(response, list, "物品赔付数据");
    }

    /**
     * 获取物品赔付详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hlPayoutsService.selectHlPayoutsById(id));
    }

    /**
     * 新增物品赔付
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:add')")
    @Log(title = "物品赔付", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlPayouts hlPayouts)
    {
        return toAjax(hlPayoutsService.insertHlPayouts(hlPayouts));
    }

    /**
     * 修改物品赔付
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:edit')")
    @Log(title = "物品赔付", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlPayouts hlPayouts)
    {
        return toAjax(hlPayoutsService.updateHlPayouts(hlPayouts));
    }

    /**
     * 删除物品赔付
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlpayouts:remove')")
    @Log(title = "物品赔付", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hlPayoutsService.deleteHlPayoutsByIds(ids));
    }
}
